package com.pubsys.main.client.obsoleto;

import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.Grid;
import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.HasHorizontalAlignment;
import com.google.gwt.user.client.ui.HasVerticalAlignment;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.ListBox;
import com.google.gwt.user.client.ui.TextBox;
import com.google.gwt.user.client.ui.VerticalPanel;
import com.google.gwt.user.client.ui.Widget;

class ConsultaForm extends Composite implements ClickHandler{

	private VerticalPanel vPanelMaster = new VerticalPanel();
	private Grid grdPanelFilter;
	private VerticalPanel vPanelResult = new VerticalPanel();	
	private TextBox txbAutor = new TextBox();
	private TextBox txbTitulo = new TextBox();
	private TextBox txbAno = new TextBox();
	private ListBox lbxTipo = new ListBox();
	Button btnConsultar = new Button();

	public ConsultaForm() {
				
		grdPanelFilter = new Grid(5, 2);

		Label lblAutor = new Label("Autor:");
		grdPanelFilter.setWidget(0, 0, lblAutor);
		grdPanelFilter.setWidget(0, 1, txbAutor);

		Label lblTitulo = new Label("Titulo:");
		grdPanelFilter.setWidget(1, 0, lblTitulo);
		grdPanelFilter.setWidget(1, 1, txbTitulo);

		Label lblAno = new Label("Ano:");
		grdPanelFilter.setWidget(2, 0, lblAno);
		grdPanelFilter.setWidget(2, 1, txbAno);
		
		lbxTipo.addItem("Inproceedings");
		lbxTipo.addItem("Incollections");
		lbxTipo.addItem("Chapters");
		lbxTipo.addItem("Individual work");
		lbxTipo.addItem("Proceedings");
		lbxTipo.addItem("Collections");
		lbxTipo.addItem("Books");
		lbxTipo.addItem("RFC");
		lbxTipo.addItem("Norma");
		lbxTipo.setVisibleItemCount(1);
		
		Label lblTipo = new Label("Tipo:");
		grdPanelFilter.setWidget(3, 0, lblTipo);
		grdPanelFilter.setWidget(3, 1, lbxTipo);
		
		btnConsultar.setText("Consultar");
		
		btnConsultar.addClickHandler(this);

		grdPanelFilter.getCellFormatter().setAlignment(4, 1,
				HasHorizontalAlignment.ALIGN_RIGHT,
				HasVerticalAlignment.ALIGN_MIDDLE);

		grdPanelFilter.setWidget(4, 1, btnConsultar);
		
		/*um comment soh pra ver se commita a bustica...*/
		
		vPanelMaster.add(grdPanelFilter);
		vPanelMaster.add(vPanelResult);
				
		// All composites must call initWidget() in their constructors.
		initWidget(vPanelMaster);

		// Give the overall composite a style name.
		setStyleName("ConsultaForm");

	}

	public void onClick(ClickEvent event) {
		Widget sender = (Widget) event.getSource();

		if (sender == btnConsultar) {
			vPanelMaster.remove(vPanelResult);
			vPanelResult = new VerticalPanel();
			HTML html1 = new HTML("Zakaria Maamar, Noura Faci, Youakim Badr, Leandro Krug Wives, Pédro Bispo dos Santos, Djamal Benslimane, José Palazzo Moreira de Oliveira: <b>Towards a framework for weaving social networks principles into web services discovery.</b> WIMS 2011: 51");
			HTML html2 = new HTML("Zakaria Maamar, Pédro Bispo dos Santos, Leandro Krug Wives, Youakim Badr, Noura Faci, José Palazzo Moreira de Oliveira: <b>Using Social Networks for Web Services Discovery.</b> IEEE Internet Computing 15(4): 48-54 (2011)");
			HTML html3 = new HTML("Juliana Bonato dos Santos, Carlos A. Heuser, Viviane Pereira Moreira, Leandro Krug Wives: <b>Automatic threshold estimation for data matching applications.<b> Inf. Sci. 181(13): 2685-2699 (2011)");
			HTML html4 = new HTML("Zakaria Maamar, Leandro Krug Wives, Youakim Badr, Said Elnaffar, Khouloud Boukadi, Noura Faci: LinkedWS: <b>A novel Web services discovery model based on the Metaphor of \"social networks\".</b> Simulation Modelling Practice and Theory 19(1): 121-132 (2011)");
			vPanelResult.add(html1);
			vPanelResult.add(html2);
			vPanelResult.add(html3);
			vPanelResult.add(html4);
			vPanelMaster.add(vPanelResult);
		} 
	}

}
